﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MyEighthWPFDemo
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        protected int eventCounter = 0;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_MouseUp(object sender, RoutedEventArgs e)
        {
            //冒泡路由，向上传递  隧道路由，向下传递       隧道事件总是在冒泡事件之前触发
            eventCounter++;
            string message = $"{eventCounter.ToString()}:\r\n Sender: {sender.ToString()}\r\n Source: {e.Source}\r\n Original Source: {e.OriginalSource} Event: {e.RoutedEvent}";
            lstMessage.Items.Add(message);
            e.Handled = (bool)chkHandle.IsChecked;  //选择了就不再传递
        }

        private void cmdClear_Click(object sender,RoutedEventArgs e)
        {
            eventCounter = 0;
            lstMessage.Items.Clear();
        }
    }
}
